<template>
	<view class="main">
		<view class="content">
			<scroll-view class="scrollView" scroll-y="true" @scrolltolower="handleScrolltolowerone()"
				:style="{height: setcollapseheight() - 50 + 'px'}">
				<view style="padding-bottom: 20rpx;">
					<view v-if="myPostList.length>0">
						<view class="contentItem" v-for="(it,index) in myPostList" :key="index" @click="goInfo(it)">
							<view class="header">
								<view class="serialnumber"></view>
								<view class="title">
									{{it.invitationTitle}}
								</view>
								<view class="right">
									<view class="img1" v-if="it.topFlag">
										<view class="line"></view>
										置顶
										<view class="san">
										</view>
									</view>
									<view class="img2" v-if="it.choicenessFlag">
										<view class="line"></view>
										精
									</view>
									<view class="newReply" v-if="!it.exchangeNewIsSelf">
										<template style="position: relative;">
											<view class="txt">
												新回复
											</view>
										</template>
									</view>
								</view>
							</view>
							<view class="container">
								<view class="img">
									<image src="@/static/index-message/V.png"></image>
								</view>
								<view class="text">
									{{it.invitationContent}}
								</view>
							</view>
							<view class="container">
								<view class="img3">
									<image src="@/static/index-message/jingliren.png"></image>
								</view>
								<view class="text" v-if="it.publisher">
									问帖人：{{it.publisher.nickName}}
								</view>
								<view class="text" v-else>
									问帖人：{{undefined}}
								</view>
							</view>
							<view class="container">
								<view class="img4">
									<image src="@/static/index-message/unit.png"></image>
								</view>
								<view class="text">
									问帖时间：{{it.createTime}}
								</view>
							</view>
							<view class="container">
								<view class="img4">
									<image src="@/static/index-message/liulanliang.png"></image>
								</view>
								<view class="text">
									浏览量：{{it.pageView}}
								</view>
							</view>
							<!-- <view>
								<view class="solution" v-if="it.resolveFlag">
									专家已解答
								</view>
								<view class="unsolution" v-else>
									专家未解答
								</view>
							</view> -->
							<!-- 是否有新回复 -->
						</view>
					</view>
					<view v-else>
						<view class="blank">
							<image src="@/static/blank.png" mode=""></image>
							<view class="nodata">
								暂无数据
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				viewReply: {
					name: 'viewreply'
				},
				myData: [],
			}
		},
		props: {
			myPostList: {
				type: Array,
				default () {
					return []
				}
			},
			tabIndex: {
				type: Number,
				default () {
					return 0
				}
			}
		},
		onShow() {
			this.myData = this.myPostList
		},
		methods: {
			//  设置可选择设施高度
			setcollapseheight() {
				let winHeight = 0
				let topheightone = uni.upx2px(136)
				uni.getSystemInfo({
					success: function(res) {
						winHeight = res.windowHeight
					}
				})
				let oldHeight = uni.upx2px(136)
				winHeight = parseInt(winHeight) - topheightone - oldHeight
				// #ifndef H5
				winHeight = winHeight - 10
				// #endif
				return winHeight
			},
			handleScrolltolowerone() {
				let arr = this.myPostList
				this.$emit('scrollView')
			},
			goInfo(row) {
				let id = row.invitationId
				if (this.tabIndex === 0) {
					uni.redirectTo({
						url: `/subPage1/socialized-service/specialist-consultation/user-module/my-interrogation/unResolve-detail/unResolve-detail?id=${id}`
					})
					console.log('哈哈');
				} else {
					uni.redirectTo({
						url: `/subPage1/socialized-service/specialist-consultation/user-module/my-interrogation/interrogation-details/interrogation-details?id=${id}`
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		// padding-top: 330rpx;
		width: 100%;
		background: #F5F6FA;

		.content {
			position: relative;
			background: #F5F6FA;

			.blank {
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translateX(-50%) translateY(-50%);
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				margin: 0 32rpx;
				margin-top: 16rpx;

				image {
					width: 200rpx;
					height: 200rpx;
				}

				.nodata {
					margin-top: 20rpx;
				}
			}

			// 主体内容
			.contentItem {
				position: relative;
				// margin: 0 40rpx;
				margin-top: 16rpx;
				background-color: #FFFFFF;
				padding: 36rpx 12rpx 40rpx 12rpx;
				box-shadow: 0rpx 0rpx 12rpx 2rpx rgba(0, 0, 0, 0.05);
				border-radius: 16rpx 16rpx 16rpx 16rpx;

				.header {
					display: flex;
					justify-content: space-between;
					position: relative;

					.serialnumber {
						position: absolute;
						top: 8rpx;
						left: 0;
						width: 10rpx;
						height: 28rpx;
						background-color: #91743E;
					}

					.title {
						padding-left: 24rpx;
						font-size: 32rpx;
						font-weight: 500;
						color: #91743E;
						width: 50%;
						text-overflow: ellipsis;
						overflow: hidden;
						white-space: nowrap;
					}

					.right {
						display: flex;
						// TODO:三角形
						.img1,
						.img2 {
							position: relative;
							top: -26rpx;
							width: 60rpx;
							height: 60rpx;
							text-align: center;
							color: #fff;
							background-color: #fa9f03;

							.line {
								position: absolute;
								top: -10rpx;
								width: 60rpx;
								height: 4rpx;
								background-color: red;
								border-radius: 6rpx;
								background-color: #fa9f03;
							}

							.san {
								position: absolute;
								top: 5rpx;
								border: 30rpx solid red;
								border-color: transparent transparent #fff transparent;
							}
						}

						.img2 {
							margin-left: 20rpx;
							background-color: #ff7072;
							border-radius: 0 0 10rpx 10rpx;

							.line {
								background-color: #ff7072;
							}
						}

						.newReply {
							position: relative;
							width: 148rpx;
							height: 152rpx;
							right: -20rpx;
							top: -30rpx;
							background: url('@/static/index-message/replay.png') no-repeat 100% 100%;

							.txt {
								position: absolute;
								transform: rotate(45deg);
								right: 32rpx;
								top: 30rpx;
								color: #fff;
							}
						}
					}

				}

				.container {
					display: flex;
					align-items: center;
					margin-left: 32rpx;
					margin-right: 10rpx;
					margin-top: 30rpx;
					font-size: 28rpx;
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					font-weight: 400;
					color: #272727;

					// text-overflow: ellipsis;
					// display: -webkit-box;
					// -webkit-box-orient: vertical;
					// -webkit-line-clamp: 3;
					// overflow: hidden;
					.img {
						width: 35rpx;
						height: 30rpx;

						image {
							position: relative;
							z-index: 999;
							width: 35rpx;
							height: 30rpx;
						}
					}

					.img3 {
						width: 30rpx;
						height: 30rpx;

						image {
							position: relative;
							z-index: 999;
							width: 27rpx;
							height: 35rpx;
						}
					}

					.img4 {
						width: 35rpx;
						height: 26rpx;

						image {
							position: relative;
							z-index: 999;
							width: 35rpx;
							height: 26rpx;
						}
					}

					.text {
						padding-left: 24rpx;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 1;
						overflow: hidden;
					}
				}

				.solution,
				.unsolution {
					position: absolute;
					width: 220rpx;
					height: 48rpx;
					right: 0;
					bottom: 0;
					font-size: 28rpx;
					font-family: Arial-Bold, Arial;
					font-weight: 400;
					color: #fff;
					text-align: center;
					line-height: 48rpx;
					background: linear-gradient(135deg, #00B2B2 0%, #00B790 100%);
					border-radius: 10rpx 0rpx 10rpx 0rpx;
				}

				.unsolution {
					background: linear-gradient(135deg, #FF6E6E 0%, #F73737 100%);
				}

			}

			.contentItem:last-child {
				// margin-bottom: 150rpx;

			}
		}
	}

	// .scrollView {
	// 	padding-top: 320rpx;
	// }
</style>